#!/bin/bash

echo "=== 简化调试脚本 ==="
echo ""
echo "选择调试方法："
echo "1) AddressSanitizer (推荐) - 自动检测内存错误"
echo "2) lldb调试器 - 交互式调试"
echo "3) 正常运行，但启用详细日志"
echo ""
read -p "请选择 (1-3): " choice

case $choice in
    1)
        echo "启动AddressSanitizer版本..."
        export ASAN_OPTIONS="verbosity=1:halt_on_error=1:print_stacktrace=1:symbolize=1:detect_leaks=1"
        ./build_asan/bin/LongImageReader 2>&1 | tee asan_output.log
        ;;
    2)
        echo "启动lldb调试器..."
        lldb ./build_asan/bin/LongImageReader
        ;;
    3)
        echo "启动正常版本，详细日志..."
        ./build/bin/LongImageReader 2>&1 | tee normal_debug.log
        ;;
    *)
        echo "无效选择"
        exit 1
        ;;
esac